/**
 * 
 */
package com.yst.metho.web.application.projectversion.actions.version;

import nextapp.echo2.app.Extent;
import nextapp.echo2.app.event.ActionEvent;

import com.yst.metho.web.application.SuiviProdApp;
import com.yst.metho.web.application.components.GenericEditWindow;
import com.yst.metho.web.application.components.listingview.ToolbarAction;
import com.yst.metho.web.application.projectversion.views.ProjectVersionPane;
import com.yst.metho.web.application.projectversion.views.ProjectVersionTableModel;
import com.yst.suivi.data.project.Project;
import com.yst.suivi.data.rights.Right;
import com.yst.suivi.status.StatusConstants;

/**
 * @author perso
 * 
 */
public class CreatePrjVersion extends ToolbarAction
{
	private ProjectVersionTableModel mModel;

	private Project mProject;

	/**
	 * 
	 */
	private static final String CREATE_USER_COMMAND = "CreateProjectVersion";

	public CreatePrjVersion(ProjectVersionTableModel model, Project project)
	{
		super(Right.CREATE_PROJECT_VERSION, "Create");
		mProject = project;
		mModel = model;
		setActionCommand(CREATE_USER_COMMAND);
		addActionListener(this);
		if (StatusConstants.CLOSE == mProject.getStatus())
		{
			setEnabled(false);
		}
	}

	public void actionPerformed(ActionEvent e)
	{
		if (CREATE_USER_COMMAND.equals(e.getActionCommand()))
		{
			ProjectVersionPane view = new ProjectVersionPane(mProject);
			GenericEditWindow window = new GenericEditWindow(view, "Version", new PrjVersionBtn(mModel, view));
			window.setHeight(new Extent(200, Extent.PX));
			SuiviProdApp.getApp().getDefaultWindow().getContent().add(window);
		}
	}
}
